
import { env } from '@/utils/env'
import http from './http'
import type { Project } from '@/types/Project'
import type { ResponeData } from '@/types/HttpType'
import type { PageData } from '@/types/PageData'


export const postProject = async (data: Project):Promise<ResponeData<Project>> => {
    return await http<Project>({
        url: env.VITE_JIANCAI + '/project/add',
        method: 'post',
        data
    })
    
}

export const putProject = async (data: Project):Promise<ResponeData<Project>> => {
    return await http<Project>({
        url: env.VITE_JIANCAI + '/project/update',
        method: 'put',
        data
    })
    

}

export const getProjectList = async (params:any):Promise<ResponeData<PageData<Project>>> => {
    return await http<PageData<Project>>({
        url: env.VITE_JIANCAI + '/project/list',
        method: 'get',
        params
    })
}

export const getProjectDetail = async (id:number):Promise<ResponeData<Project>> => {
    return await http<Project>({
        url: env.VITE_JIANCAI + '/project/detail/' + id,
        method: 'get',
    })
}

export const deleteProject = async (id: number):Promise<any> => {
    let res = await http<any>({
        url: env.VITE_JIANCAI + '/project/delete/' + id,
        method: 'delete',
    })
    return res
}
